cmake_minimum_required(VERSION 3.16)
project(cuda_example LANGUAGES CXX CUDA)
# set(CMAKE_VERBOSE_MAKEFILE ON)

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3")
# set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -O0 -g3")
# 设置C++标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置CUDA标准
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

# 根据GPU架构设置，可根据实际情况调整
set(CMAKE_CUDA_ARCHITECTURES 87)

# 查找CUDA库
find_package(CUDA REQUIRED)

# 包含CUDA头文件目录
include_directories(${CUDA_INCLUDE_DIRS})

add_definitions(-DSIM_TEST=1)

# 定义源文件
set(SOURCES
    test.cc
    cuda_cal.cu
)

# 定义头文件
set(HEADERS
    cuda_cal.h
)

# 创建可执行文件
# add_executable(cuda_example ${SOURCES} ${HEADERS})
add_executable(cuda_example
    # test.cc
    cuda_cal.cu
)

# 链接CUDA库
target_link_libraries(cuda_example ${CUDA_LIBRARIES})

# 设置CUDA编译选项
set_target_properties(cuda_example PROPERTIES
    CUDA_SEPARABLE_COMPILATION ON
    CUDA_RESOLVE_DEVICE_SYMBOLS ON
)
